﻿namespace CSharpPro._1103;

using System.Collections.Generic;

/// <summary>
/// 用户服务接口
/// 定义用户管理的核心业务逻辑
/// </summary>
public interface IUserService
{
    /// <summary>
    /// 用户注册
    /// </summary>
    /// <param name="username">用户名</param>
    /// <param name="password">密码</param>
    /// <param name="confirmPassword">确认密码</param>
    /// <returns>注册是否成功</returns>
    bool Register(string username, string password, string confirmPassword);
    
    /// <summary>
    /// 用户登录
    /// </summary>
    /// <param name="username">用户名</param>
    /// <param name="password">密码</param>
    /// <returns>登录是否成功</returns>
    bool Login(string username, string password);
    
    /// <summary>
    /// 修改密码
    /// </summary>
    /// <param name="username">用户名</param>
    /// <param name="oldPassword">原密码</param>
    /// <param name="newPassword">新密码</param>
    /// <param name="confirmNewPassword">确认新密码</param>
    /// <returns>修改是否成功</returns>
    bool ChangePassword(string username, string oldPassword, string newPassword, string confirmNewPassword);
    
    /// <summary>
    /// 获取用户信息
    /// </summary>
    /// <param name="username">用户名</param>
    /// <returns>用户对象，如果不存在返回null</returns>
    User GetUserInfo(string username);
    
    /// <summary>
    /// 获取所有用户列表
    /// </summary>
    /// <returns>用户列表</returns>
    List<User> GetAllUsers();
    
    /// <summary>
    /// 删除用户
    /// </summary>
    /// <param name="username">用户名</param>
    /// <returns>删除是否成功</returns>
    bool DeleteUser(string username);
    
    /// <summary>
    /// 检查用户名是否存在
    /// </summary>
    /// <param name="username">用户名</param>
    /// <returns>是否存在</returns>
    bool IsUsernameExists(string username);
    
    /// <summary>
    /// 验证用户名格式
    /// </summary>
    /// <param name="username">用户名</param>
    /// <returns>格式是否正确</returns>
    bool ValidateUsername(string username);
    
    /// <summary>
    /// 验证密码格式
    /// </summary>
    /// <param name="password">密码</param>
    /// <returns>格式是否正确</returns>
    bool ValidatePassword(string password);
    
    /// <summary>
    /// 获取用户数量
    /// </summary>
    /// <returns>用户总数</returns>
    int GetUserCount();
    
    /// <summary>
    /// 搜索用户（按用户名模糊搜索）
    /// </summary>
    /// <param name="keyword">关键词</param>
    /// <returns>匹配的用户列表</returns>
    List<User> SearchUsers(string keyword);
    
    /// <summary>
    /// 更新用户信息
    /// </summary>
    /// <param name="user">用户对象</param>
    /// <returns>更新是否成功</returns>
    bool UpdateUser(User user);
}
